package kz.epam.apartment;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import kz.epam.homedevices.ElectricalDevice;

/**
 *
 * @author Knoppix
 */
public class Flat {

    private List<ElectricalDevice> devices = new ArrayList<>();

    public Flat(List<ElectricalDevice> devices) {
        this.devices = devices;
    }

    public Flat() {
    }

    @Override
    public String toString() {
        return "Flat devices=" + devices;
    }

    public List<ElectricalDevice> getDevices() {
        return devices;
    }

    public void setDevices(List<ElectricalDevice> devices) {
        this.devices = devices;
    }

    public double totalCardinality() {
        double totalCardinality = 0;
        for (int i = 0; i < devices.size(); i++) {
            totalCardinality += devices.get(i).getCardinality();
        }
        return totalCardinality;
    }

    public void diaposonOut() {
        Scanner scanner = new Scanner(System.in);
        double min; //Начальная граница
        double max; //Конечная граница
        double buf;
        System.out.println("Enter the initial range");
        min = scanner.nextDouble();
        System.out.println("Enter the target range");
        max = scanner.nextDouble();

        if (min > max) {
           buf = min;
           min = max;
           max = buf;
        }

        for (int i = 0; i < devices.size(); i++) {
            if (min <= devices.get(i).getCardinality() && max >= devices.get(i).getCardinality()) {
            System.out.print(devices.get(i));
            }
        }
    }
}
